package com.cet.reactor;

import reactor.core.publisher.Flux;

public class ErrorHandleDemo {

    public static void main(String[] args) {

        // 错误都是terminal event

        Flux.just(1, 2, 0)
                .map(i -> "100 / " + i + " = " + (100 / i)) //this triggers an error with 0
                .onErrorReturn("Divided by zero :(")
                .subscribe(
                        v -> System.out.println("v=" + v),
                        error -> System.out.println("error=" + error),
                        () -> {
                            System.out.println("流结束");
                        });
    }
}


